package cn.lutu.lutuspringboot.aopUtil;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class ServiceTimerAspect {

    @Around("execution(* cn.lutu.domain..service.*.*(..))")
    public Object timer(ProceedingJoinPoint pjp) throws Throwable {
        long start = System.currentTimeMillis();
        Object proceedResult = pjp.proceed();
        long end = System.currentTimeMillis();
        log.info("执行耗时："+(end-start));
        return proceedResult;
    }
}
